package com.ruoyi.web.controller.sincerity;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SinScore;
import com.ruoyi.system.service.ISinScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生分值Controller
 *
 * @author buke
 * @date 2023-04-15
 */
@RestController
@RequestMapping("/system/score")
public class SinScoreController extends BaseController
{
    @Autowired
    private ISinScoreService sinScoreService;

    /**
     * 查询学生分值列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(SinScore sinScore)
    {
        startPage();
        List<SinScore> list = sinScoreService.selectSinScoreList(sinScore);
        return getDataTable(list);
    }

    /**
     * 导出学生分值列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:export')")
    @Log(title = "学生分值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SinScore sinScore)
    {
        List<SinScore> list = sinScoreService.selectSinScoreList(sinScore);
        ExcelUtil<SinScore> util = new ExcelUtil<SinScore>(SinScore.class);
        util.exportExcel(response, list, "学生分值数据");
    }

    /**
     * 获取学生分值详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sinScoreService.selectSinScoreById(id));
    }

    /**
     * 新增学生分值
     */
    @PreAuthorize("@ss.hasPermi('system:score:add')")
    @Log(title = "学生分值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SinScore sinScore)
    {
        return toAjax(sinScoreService.insertSinScore(sinScore));
    }

    /**
     * 修改学生分值
     */
    @PreAuthorize("@ss.hasPermi('system:score:edit')")
    @Log(title = "学生分值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SinScore sinScore)
    {
        return toAjax(sinScoreService.updateSinScore(sinScore));
    }

    /**
     * 删除学生分值
     */
    @PreAuthorize("@ss.hasPermi('system:score:remove')")
    @Log(title = "学生分值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sinScoreService.deleteSinScoreByIds(ids));
    }
}
